package com.lmc.form;

import com.alibaba.druid.pool.DruidDataSource;
import com.free.bsf.core.filter.CORSFilter;
import com.lmc.form.script.FormEventFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import javax.sql.DataSource;

@Configuration
public class WebConfiguration {
    @ConfigurationProperties("spring.datasource.mysql")
    @Bean(name="paasDataSource",destroyMethod="close")
    @Lazy
    public DataSource paasDataSource(){
        return (DruidDataSource) DataSourceBuilder.create().type(DruidDataSource.class).build();
    }

    @Bean
    public FormEventFilter formEventFilter() {
        return new FormEventFilter();
    }
}